<template>
  <!--  main-->
  <!--  <van-button type="primary" @click="getUserInfo" >获取信息</van-button>-->
  <!--  <br>-->
  <!--  <van-button type="primary" @click="getUserInfo2" >执行</van-button>-->

  <van-card v-for="user in userList"
            :desc="user.userRole"
            :title="user.username"
            :thumb="user.avatarUrl"
  >
    <template #tags>
      <van-tag v-for="tag in user.tags" style="margin-right: 8px;margin-top: 8px" plain type="danger">{{ tag }}
      </van-tag>
    </template>
    <template #footer>
      <van-button size="mini" @click="getContact(user)">获取联系方式</van-button>
      <!--      <van-button size="mini">按钮</van-button>-->
    </template>
  </van-card>
</template>

<script setup>

import {onMounted, ref, inject} from "vue";
import {Toast} from "vant";
import {useRouter, useRoute} from "vue-router";
import {isAuthenticated, setAuthToken,getAuthToken} from "../utils/auth.js";

const router = useRouter()
const useRoute1 = useRoute()

// 控制全局变量  是否展示 底部操作框
const globalVariable = inject('globalVariable');
onMounted(async () => {
  userList.value = [userInfo.value, userInfo.value];
  console.log("数据打印2" + globalVariable.value)
  globalVariable.value = true;
  console.log("数据打印2" + globalVariable.value)
})

const userInfo = ref({
  id: '1973',
  username: 'MC-大雷虎先锋',
  userAccount: 'Tcc.5267',
  avatarUrl: 'https://tccbucket.oss-cn-beijing.aliyuncs.com/%E5%B0%8F%E5%86%B0.jpg',
  gender: '男',
  phone: '18027942111',
  email: '6211@azr0.cn',
  userStatus: '正常',
  userRole: '管理员',
  planetCode: 'Tcc',
  tags: ['Java', 'Vue'],
  createTime: new Date(),
})

const getContact = (value) => {
  Toast.success('奴才这就去办~！');
  console.log(isAuthenticated())
  setAuthToken("猕猴桃")
  console.log(isAuthenticated())
  console.log(getAuthToken())

}
const userList = ref([])

</script>
<style scoped>

</style>